var expect = require('chai').expect,sinon = require('sinon');
var rewire = require('rewire');
var bizKeyControllerTest = rewire('../../controller/bizKeyController');
var mongoose = require('../../utils/mongodb');

describe('operation about bizKeyType',function(){

    it('insert bizKeyType',function(done){
        //Given
        let req = {
            body:{
                params:[{
                    bizKeyType:'shipmentNumber',
                    bizKeyValue:'123456789'
                }]
            }
        };
        let res = {
            response : '',
            send : function (response) {
                this.response = response;
            }
        };
        let error = {

        };

        //When
        bizKeyControllerTest.insertBizKeyType(req,res,error);
        done();

    });

    it('test private getTargetBizKeyTypeList', function () {
        //Given
        let getTargetBizKeyTypeList = bizKeyControllerTest.__get__('getTargetBizKeyTypeList');
        let res = {
            response : '',
            send : function (response) {
                this.response = response;
            }
        };
        let params = {
                    allBizKeyTypeList:
                        [ { _id: 'SHPNumber', type: 'shipmentNumber' },
                            { _id: 'CMSReference', type: 'CMSReference' },
                            { _id: 'BLID', type: 'BLID' },
                            { _id: 'jdfjdkf', type: 'jdfjdkf', __v: 0 },
                            { _id: 'djfkfj', type: 'djfkfj', __v: 0 },
                            { _id: 'shipmentNumber', type: 'shipmentNumber' },
                            { _id: 'ppppp', type: 'ppppp' },
                            { _id: '555555', type: '555555' },
                            { _id: 'ShipmentNumber', type: 'ShipmentNumber' },
                            { _id: 'aaa', type: 'aaa' } ],
                    originalBizKeyList:
                        [ { _id: '5b163c15ab12275d79f213fe',
                            bizKeyType: 'shipMentNumber',
                            bizKeyValue: '4045450070' },
                          { _id: '5b165cc66052061b11493125',
                            bizKeyType: 'RoutePointID',
                            bizKeyValue: '434343' } ],
                    res: {
                        response : '',
                        send : function (response) {
                            this.response = response;
                        }
                    }
                };

        let targetResult = getTargetBizKeyTypeList(params);
        let expectResult = [
            {
                _id : 'RoutePointID',
                type : 'RoutePointID'
            }
        ];
        //Then
        expect(JSON.stringify(expectResult)).to.be.equal(JSON.stringify(targetResult.targetBizKeyType));
    });
});